package com.hnevc.netdemo;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

public class UDPSenderDemo {

	public static void main(String[] args) throws IOException {
		DatagramSocket ds = new DatagramSocket();
		String data = "你好";
		byte[] datas = data.getBytes();
		DatagramPacket dp = new DatagramPacket(datas, datas.length, 
				InetAddress.getByAddress(new byte[]{127,0,0,1}), 
				20000);
		System.out.println("发送消息");
		ds.send(dp);
		ds.close();
	}

}
